/*
 * Copyright 2007-2009 Perttu "celeron55" Ahola <celeron55@gmail.com>
 *
 * This file is part of jukumagic.
 *
 * jukumagic is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * jukumagic is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with jukumagic.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef NET_H_
#define NET_H_

#include "common.h"
#include "jukuobject.h"
#include <list>
#include <set>

class Board;

class NetPin
{
public:
	NetPin(){}
	NetPin(const wxString &refdes, const wxString &num){m_refdes = refdes; m_num = num;}
	wxString m_refdes;
	wxString m_num;
	wxString m_netid; //used in spice import
	bool operator==(const NetPin &p){return (m_refdes==p.m_refdes && m_num==p.m_num);}
};

enum NetValidity
{
	NET_VALID,
	NET_LACKS_PINS,
	NET_INVALID_PIN
};

class Net : public JukuObject
{
public:
	wxString m_name;
	std::list<NetPin> m_pins;
	NetValidity m_validity;
	Net();
	~Net();
    JukuObjectType GetType(){ return TYPE_NET; }
	const wxChar * GetShortString(void){return NULL;}
	const wxChar * GetTypeString(void){return _("Net");}
	void WriteXML(TiXmlNode* root);
	static JukuObject* ReadFromXMLElement(TiXmlElement* element);
	bool HavePin(const NetPin &p);
	void GetPoints(Board *board, std::set<int> &points);
};

#endif
